package demo1;

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int left = scanner.nextInt();
        int right = scanner.nextInt();
        int count = 0;
        for (int i = left; i <= right ; i++) {
            count += howMuch2(i);
        }
        System.out.println(count);
    }

    private static int howMuch2(int i) {
        int count = 0;

        while (i != 0){
            if (i%10==2){
                count++;
            }
            i /= 10;
        }
        return count;
    }
}
